package com.chenfan.magic.exception;

import com.chenfan.magic.base.R;
import lombok.Getter;

import java.util.Map;

/**
 * 自定义异常
 *
 * @author troy
 */
public class MagicDebugException extends RuntimeException {
    private static final long serialVersionUID = 2359767895161832957L;

    @Getter
    private R r;

    public MagicDebugException(int code, String message) {
        super(message);
        this.r = R.fail(code, message);
    }

    public MagicDebugException(String message, int code) {
        super(message);
        this.r = R.fail(code, message);
    }

    public MagicDebugException(String message, int code, Map<String, Object> map) {
        super(message);
        this.r = R.fail(code, message).putAll(map);
    }

    public MagicDebugException(String message) {
        super(message);
        this.r = R.fail(5000000, message);
    }

    public MagicDebugException(R r) {
        super(r.getMsg());
        this.r = r;
    }

    public MagicDebugException(R r, Throwable cause) {
        super(cause);
        this.r = r;
    }

    @Override
    public Throwable fillInStackTrace() {
        return this;
    }
}
